/**
 * Copyright &copy; 2012-2014 <a href="https://github.com/someone/qs">qs</a> All rights reserved.
 */
package com.chain.qs.common.utils;

import org.apache.activemq.command.ActiveMQBytesMessage;

import java.util.*;

/**
 * 类型转换工具类
 *
 * @author fgx
 * @version 2017-1-10
 */
@SuppressWarnings("unchecked")
public class CastUtils {

    public static HashMap<String, Object> convertToHashMap(Object object) {
        try {
            return (HashMap<String, Object>) object;
        } catch (ClassCastException e) {
            e.printStackTrace();
        }
        return new HashMap<>();
    }

    public static HashMap<String, String> convertToHashMapStringString(Object object) {
        try {
            return (HashMap<String, String>) object;
        } catch (ClassCastException e) {
            e.printStackTrace();
        }
        return new HashMap<>();
    }

    public static HashMap<String, Map<String, String>> convertToDoubleHashMapStringString(Object object) {
        try {
            return (HashMap<String, Map<String, String>>) object;
        } catch (ClassCastException e) {
            e.printStackTrace();
        }
        return new HashMap<>();
    }

    public static HashMap<String, Map<String, Map<String, Map<String, Map<String, String>>>>> convertToFiveHashMapStringString(Object object) {
        try {
            return (HashMap<String, Map<String, Map<String, Map<String, Map<String, String>>>>>) object;
        } catch (ClassCastException e) {
            e.printStackTrace();
        }
        return new HashMap<>();
    }


    public static Set<String> convertToSet(Object object) {
        try {
            return (Set<String>) object;
        } catch (ClassCastException e) {
            e.printStackTrace();
        }
        return new HashSet<>();
    }

    public static ActiveMQBytesMessage convertToActiveMQBytesMessage(Object object) {
        try {
            return (ActiveMQBytesMessage) object;
        } catch (ClassCastException e) {
            e.printStackTrace();
        }
        return new ActiveMQBytesMessage();
    }

    public static List<Map> convertToListMap(Object object) {
        try {
            return (List<Map>) object;
        } catch (ClassCastException e) {
            e.printStackTrace();
        }
        return new ArrayList<>();
    }

    public static Map<String, Map<String, List<Map<String, String>>>> convertToDoubleHashMapListStringString(Object object) {
        try {
            return (Map<String, Map<String, List<Map<String, String>>>>) object;
        } catch (ClassCastException e) {
            e.printStackTrace();
        }
        return new HashMap<>();
    }
}
